package com.shiguiwu.springmybatis.designpattern.builder.scene;

import com.shiguiwu.springmybatis.designpattern.builder.scene.ceilling.LevelOneCeiling;
import com.shiguiwu.springmybatis.designpattern.builder.scene.ceilling.LevelTwoCeiling;
import com.shiguiwu.springmybatis.designpattern.builder.scene.coat.DuluxCoat;
import com.shiguiwu.springmybatis.designpattern.builder.scene.coat.LiBangCoat;
import com.shiguiwu.springmybatis.designpattern.builder.scene.floor.ShengXiangFloor;
import com.shiguiwu.springmybatis.designpattern.builder.scene.tile.DongPengTile;
import com.shiguiwu.springmybatis.designpattern.builder.scene.tile.MarcoPoloTile;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: stone
 * @date: Created by 2021/8/15 19:15
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.designpattern.builder.scene
 */
public class DecorationPackageController {


    public String getMatterList(BigDecimal area, Integer level) {

        List<Matter> list = new ArrayList<>();
        BigDecimal price = BigDecimal.ZERO;

        //豪华欧式
        if (1 == level) {
            //二级吊顶
            LevelOneCeiling levelOneCeiling = new LevelOneCeiling();
            //涂料 多乐士
            DuluxCoat duluxCoat = new DuluxCoat();
            //圣象地板
            ShengXiangFloor floor = new ShengXiangFloor();

            list.add(levelOneCeiling);
            list.add(duluxCoat);
            list.add(floor);

            //价格
            price = price.add(area.multiply(new BigDecimal("0.4")).multiply(levelOneCeiling.price()));

            price = price.add(area.multiply(new BigDecimal("1.4")).multiply(duluxCoat.price()));

            price = price.add(area.multiply(floor.price()));

        }
        // 轻奢⽥田园
        if (2 == level) {
            //一级吊顶
            LevelTwoCeiling levelTwoCeiling = new LevelTwoCeiling();
            //涂料 立邦
            LiBangCoat liBangCoat = new LiBangCoat();
            //马可波罗地板
            MarcoPoloTile tile = new MarcoPoloTile();

            list.add(levelTwoCeiling);
            list.add(liBangCoat);
            list.add(tile);

            //价格
            price = price.add(area.multiply(new BigDecimal("0.4")).multiply(levelTwoCeiling.price()));

            price = price.add(area.multiply(new BigDecimal("1.4")).multiply(liBangCoat.price()));

            price = price.add(area.multiply(tile.price()));
        }


        // 现代简约
        if (3 == level) {
            //一级吊顶
            LevelTwoCeiling ceiling = new LevelTwoCeiling();
            //涂料 立邦
            LiBangCoat liBangCoat = new LiBangCoat();
            //东鹏
            DongPengTile tile = new DongPengTile();

            list.add(ceiling);
            list.add(liBangCoat);
            list.add(tile);

            //价格
            price = price.add(area.multiply(new BigDecimal("0.4")).multiply(ceiling.price()));

            price = price.add(area.multiply(new BigDecimal("1.4")).multiply(liBangCoat.price()));

            price = price.add(area.multiply(tile.price()));
        }


        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("-------------------------------------\r\n")
                .append("装修清单\r\n").append("套餐等级：").append(level).append("\r\n").append("价格套餐：").append(price.setScale(2, BigDecimal.ROUND_HALF_UP)).append("\r\n").append("房屋面积：").append(area.doubleValue()).append("\r\n")
                .append("材料清单： \r\n");

        list.forEach(matter -> stringBuilder.append(matter.scene()).append("：").append(matter.brand()).append(
                "、").append(matter.model()).append("、平米价格：").append(matter.price()).append(" 元。\n"));
        return stringBuilder.toString();
    }

}
